package com.qingke.notlonely.bean;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name="user")
public class User {
	@Id
	@Column(name="id")
	private int id;
	@Column(name="username")
	private String username;
	@Column(name="name")
	private String name;
	@Column(name="gender")
	private String gender;
	@Column(name="age")
	private int age;
	@Column(name="mobile")
	private String mobile;
	@Column(name="height")
	private double height;
	@Column(name="weight")
	private double weight;
	@OneToOne
	@PrimaryKeyJoinColumn
	private UserPassword userPassword;
	@OneToMany(mappedBy="user",fetch=FetchType.LAZY)
	private Set<UserInterest> userInterests;
	@OneToMany(mappedBy="user",fetch=FetchType.LAZY)
	private Set<UserEduction> userEductions;
	@OneToMany(mappedBy="inviter",fetch=FetchType.LAZY)
	private Set<Yue> inviterYues;
	@OneToMany(mappedBy="invitee",fetch=FetchType.LAZY)
	private Set<Yue> inviteeYues;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public double getHeight() {
		return height;
	}
	public void setHeight(double height) {
		this.height = height;
	}
	public double getWeight() {
		return weight;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
	public UserPassword getUserPassword() {
		return userPassword;
	}
	public void setUserPassword(UserPassword userPassword) {
		this.userPassword = userPassword;
	}
	public Set<UserInterest> getUserInterests() {
		return userInterests;
	}
	public void setUserInterests(Set<UserInterest> userInterests) {
		this.userInterests = userInterests;
	}
	public Set<UserEduction> getUserEductions() {
		return userEductions;
	}
	public void setUserEductions(Set<UserEduction> userEductions) {
		this.userEductions = userEductions;
	}
	public Set<Yue> getInviterYues() {
		return inviterYues;
	}
	public void setInviterYues(Set<Yue> inviterYues) {
		this.inviterYues = inviterYues;
	}
	public Set<Yue> getInviteeYues() {
		return inviteeYues;
	}
	public void setInviteeYues(Set<Yue> inviteeYues) {
		this.inviteeYues = inviteeYues;
	}
	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", gender=" + gender + ", age=" + age + ", mobile=" + mobile
				+ ", height=" + height + ", weight=" + weight + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result + ((username == null) ? 0 : username.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (id != other.id)
			return false;
		if (username == null) {
			if (other.username != null)
				return false;
		} else if (!username.equals(other.username))
			return false;
		return true;
	}
	
	
}
